package jrunner;


 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 

public class startWindow2 extends JFrame {
  
    GridLayout windowLayout = new GridLayout(0,2);   //set cells and rows of GridLayout
     
    public startWindow2(String name) {       //wozu brauche ich diese anonyme Klasse? 
        super(name);
        setResizable(false);
    }
     
 
     
    public void addComponentsToPane(final Container pane) {
        
        final JPanel window = new JPanel();
        window.setLayout(windowLayout); 
        JPanel controls = new JPanel();
        controls.setLayout(new GridLayout(2,3));
         
        //Set up components preferred size

       
          window.setPreferredSize(new Dimension((int)(1200)+50,
                (int)(550)+100));
         
        //Add buttons to GridLayout
       
        JButton newPerson=new JButton("Create new Person");
        newPerson.addActionListener(new createnewPersonButton());
        
        JButton chooseexistingPerson= new JButton("Choose existing Person");
        JButton viewStats =new JButton("View Stats");
        JButton newrunningRoute= new JButton("Add a Running Route");
        JButton anotherButton= new JButton("another Button");
        JButton lastButton=new JButton("probably the last Button");
      
        window.add(newPerson);
        window.add(chooseexistingPerson);
        window.add(viewStats);
        window.add(newrunningRoute);
        window.add(anotherButton);
        window.add(lastButton);
        
        
        //set horizontal and vertical gaps between buttons
        windowLayout.setHgap(50);
        windowLayout.setVgap(50);
      
 
  //put Elements on the pane
        pane.add(window, BorderLayout.NORTH);
        pane.add(new JSeparator(), BorderLayout.CENTER);
        pane.add(controls, BorderLayout.SOUTH);
    }
     
    /**
     * Create the GUI and show it.  For thread safety,
     * this method is invoked from the
     * event dispatch thread.
     */
    public static void createAndShowGUI() {
        //Create and set up the window.
        startWindow2 frame = new startWindow2("JRunner STARTPAGE");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Set up the content pane.
        frame.addComponentsToPane(frame.getContentPane());
        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }
     
    public static void main(String[] args) {
        /* Use an appropriate Look and Feel */
        try {
            //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
    
         
        //Schedule a job for the event dispatch thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {       //was heißt hier inovke later?
            public void run() {
                createAndShowGUI();
            }
        });
    }

    class createnewPersonButton implements ActionListener{

		public void actionPerformed(ActionEvent ev) {
			PersonGUI newwindow= new PersonGUI();
		    newwindow.buildWindow();
			
		}		
	}



}